<include file="Public/header" title="贡献榜" hall_banner="nav_item-active"/>

     <div class="container container-rank">
            <div>
                <!-- section-subnav 标题-->
                <div class="section section-subnav">
                    <div class="section_subnav">
                        <p class="subnav_title"><a href="#">贡献榜</a></p>
                        <div class="subnav_bgtext"></div>
                    </div>
                </div>

                <div class="section section-rank">
                    <div class="section_rank">
                        <div class="rank_nav">
                            <div class="nav_rankselect">
                                <ul class="mod-grouptabs">
									<li id="total_count" class="grouptabs_item grouptabs_item-active">
                                        <a href="{:U('hall/index')}">总排行榜</a>
                                    </li>
									<li id="year_count" class="grouptabs_item">
                                        <a href="javascript:query_hall('year');">年排行榜</a>
                                    </li>
                                    <li id="month_count" class="grouptabs_item">
                                        <a href="javascript:query_hall('month');">月排行榜</a>
                                    </li>
                                </ul>
                                <div class="rankselect_form">
                                    <div class="form_time">
                                        <label for="">时间</label>
                                        <select name="" id="year_val">
											<option value="all">全部</option>
											<foreach name="year_hub" item="year">
                                            <option value="{$year}">{$year}年</option>
											</foreach>
                                        </select>
                                        <select name="" id="month_val" onchange="query_hall_by_day();">
											<option value="all">全部</option>
                                            <option value="1">1月</option>
                                            <option value="2">2月</option>
                                            <option value="3">3月</option>
                                            <option value="4">4月</option>
                                            <option value="5">5月</option>
                                            <option value="6">6月</option>
                                            <option value="7">7月</option>
                                            <option value="8">8月</option>
                                            <option value="9">9月</option>
                                            <option value="10">10月</option>
                                            <option value="11">11月</option>
                                            <option value="12">12月</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <table class="rank_table">
                            <thead>
                                <tr>
                                    <th class="th-1">排行</th>
                                    <th class="th-2">昵称</th>
                                    <th class="th-3">团队</th>
                                    <th class="th-5">贡献值</th>
                                </tr>
                            </thead>
                            <tbody id="tbody">
								<foreach name="user" key="k" item="v">
                                <tr id="hall_recored">
                                    <td class="td-rank-{$k+1}"><i>{$k+1}</i></td>
                                    <td><img class="mod-avatar mod-avatar-50" src="__PUBLIC__/Uploads/{$v.avatar}" alt=""><a href="{:U('hall/view?pid=')}{$v['pid']}">{$v['username']}</a></td>
                                    <td>{$v['team']}</td>
                                    <td>{$v['total_points']}</td>
                                </tr>
								</foreach>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
		<script>
		function query_hall(range_val){
							$.ajax({
								url: "__ROOT__/index.php?m=user&c=hall&a=sortdata",
								type: "POST",
								data: {range:range_val},
								success: function (data) {
									var myDate = new Date();
									var year_num = myDate.getFullYear();
									var month_num = myDate.getMonth()+1;
									if (range_val=="year"){
										$("#total_count").attr("class","grouptabs_item");
										$("#month_count").attr("class","grouptabs_item");
										$("#year_count").attr("class","grouptabs_item grouptabs_item-active");
										$("select option").removeAttr("selected");
										$("#year_val")>$("[value|='" + year_num + "']").attr('selected','selected');
									} else {
										$("#total_count").attr("class","grouptabs_item");
										$("#year_count").attr("class","grouptabs_item");
										$("#month_count").attr("class","grouptabs_item grouptabs_item-active");
										$("select option").removeAttr("selected");
										$("#year_val")>$("[value|='" + year_num + "']").attr('selected','selected');
										$("#month_val")>$("[value|='" + month_num + "']").attr('selected','selected');
									}
									if (data.status == "1") {
										$("#tbody").empty();
										$.each(data.result,function(i,item){
											var index = i + 1;
											$("#tbody").append("<tr id=\"hall_recored\"><td class=\"td-rank-"+ index +"\"><i>"+ index +"</i></td><td><img class=\"mod-avatar mod-avatar-50\" src=\"__PUBLIC__/Uploads/"+ item['avatar'] +"\" alt=\"\"><a href=\"{:U('hall/view?pid=')}" + item['pid'] + "\">"+ item['username'] + "</a></td><td>"+ item['team'] +"</td><td>"+ item['total_points']+"</td></tr>");
										});
									}else{
										$("#tbody").empty();
									}
									//$("#imgWait").hide();
								},
								error: function () {
									$("#address_fail").css("display","block");
								}
							});
		}
		
		function query_hall_by_day(){
							var year_val = $("#year_val").val();
							var month_val = $("#month_val").val();
							$.ajax({
								url: "__ROOT__/index.php?m=user&c=hall&a=sortdata",
								type: "POST",
								data: {range:'custom',year:year_val,month:month_val},
								success: function (data) {
									$("#total_count").attr("class","grouptabs_item");
									$("#year_count").attr("class","grouptabs_item");
									$("#month_count").attr("class","grouptabs_item grouptabs_item-active");
									if (data.status == "1") {
										$("#tbody").empty();
										$.each(data.result,function(i,item){
											var index = i + 1;
											$("#tbody").append("<tr id=\"hall_recored\"><td class=\"td-rank-"+ index +"\"><i>"+ index +"</i></td><td><img class=\"mod-avatar mod-avatar-50\" src=\"__PUBLIC__/Uploads/"+ item['avatar'] +"\" alt=\"\"><a href=\"{:U('hall/view?pid=')}" + item['pid'] + "\">"+ item['username'] + "</a></td><td>"+ item['team'] +"</td><td>"+ item['sum(points)']+"</td></tr>");
										});
									}else{
										$("#tbody").empty();
									}
								},
								error: function () {
									$("#address_fail").css("display","block");
								}
							});
		}
		</script>
<include file="Public/footer"/>